package com.example.zhyq.visit

import androidx.databinding.DataBindingUtil
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.base.entity.VisitBeanItem
import com.example.zhyq.R
import com.example.zhyq.databinding.ItemVisitBinding

class VisitAdapter : BaseQuickAdapter<VisitBeanItem, BaseViewHolder>(R.layout.item_visit) {

    lateinit var binding : ItemVisitBinding
    override fun convert(helper: BaseViewHolder, item: VisitBeanItem) {
        binding = DataBindingUtil.getBinding<ItemVisitBinding>(helper.itemView)!!
        binding.bean=item

        val tv_status = binding.visitStatus
        if (item.visitStatus=="已通过"){
            tv_status.setTextColor(context.getColor(R.color.green))
            tv_status.setBackgroundResource(R.drawable.shape_status)
        }else if(item.visitStatus=="待审核"){
            tv_status.setTextColor(context.getColor(R.color.blue))
            tv_status.setBackgroundResource(R.drawable.shap_zhanyong)
        }else if(item.visitStatus=="驳回"){
            tv_status.setTextColor(context.getColor(R.color.orange))
            tv_status.setBackgroundResource(R.drawable.shape_weihu)
        }else {
            tv_status.setTextColor(context.getColor(R.color.darkgray))
            tv_status.setBackgroundResource(R.drawable.shape_solid_lightgray)
        }
    }

    override fun onItemViewHolderCreated(viewHolder: BaseViewHolder, viewType: Int) {
        super.onItemViewHolderCreated(viewHolder, viewType)
        DataBindingUtil.bind<ItemVisitBinding>(viewHolder.itemView)
    }
}